<template>
	<view class="car-wrap u-p-l-30 u-p-r-30 u-p-t-20">
		<view v-if="this.listData.length == 0">
			<view style="width: 232px;height: 242px;margin: 110px auto;">
				<image style="width: 100%;height: 100%;" src="https://clhy-img.oss-cn-beijing.aliyuncs.com/ownerImage/zanwushuju.png"
					mode=""></image>
			</view>
			<view style="width: 62%;margin: -66px auto;text-align: center;color: #999;">暂无数据</view>
		</view>
		<view class="car-card u-m-t-20 u-p-40 u-flex-1" v-for="(item,index) in listData">
			<view class="u-font-32 u-m-b-32" style="color: #333;display: flex;">
				<image style="width: 22px;height: 22px;margin-right: 6rpx;margin-top: 2px;"
					src="https://clhy-img.oss-cn-beijing.aliyuncs.com/ownerImage/parking2.png" alt=""></image>
				<h3>{{item.parking_lot_type==1 ? '产权车位': item.parking_lot_type == 2 ? '租赁车位' :'不固定车位'}}</h3>
			</view>

			<view class="u-m-b-20 u-font-28" style="color: #666;">
				{{item.parking_lot_name}}
			</view>
			<view class="u-m-b-20 u-font-28" style="color: #666;">
				{{item.parking_lot_type == 1 || item.parking_lot_type == 2 ? '车位管理费':'不固定车位停车费'}}：{{item.cost_per_period}}/{{item.payment_cycle}}月
			</view>
			<view class="u-m-b-20 u-font-28" style="color: #666;" v-if="item.parking_lot_type != 3">
				车位号：{{item.ps_number}}
			</view>
			<view class="u-m-b-20 u-font-28" style="color: #666;" v-if="item.parking_lot_type != 1">
				合同周期：{{item.contract_cycle_start}}至{{item.contract_cycle_last}}
			</view>
			<view class="u-m-b-20 u-font-28" style="color: #666;">
				车牌号：{{item.driving_number}}
			</view>
			<view class="u-m-b-20 u-font-28" style="color: #666;">
				车型：{{item.driving_model}}
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				loadText: {
					loadmore: '轻轻上拉加载更多',
					loading: '努力加载中',
					nomore: '实在没有了'
				},
				listData: [],
				searchData: {},
				pageInfo: {
					page: 1
				},
				pageIndex: 1,
				loading: false,
				// type: 1,
				nextPage: false,
			}
		},
		onLoad() {
			this.checkLogin();
		},
		onPullDownRefresh() {
			this.getList();
		},
		methods: {
			// 验证是否登录或实名认证
			checkLogin() {
				let _this = this
				if (uni.getStorageSync('phone')) {
					if (uni.getStorageSync('loginFlag')) {
						if (!uni.getStorageSync('hourseList')) {
							uni.showModal({
								title: '请先进行业主认证',
								showCancel: false,
								confirmText: '确认',
								confirmColor: '#F9A832',
								success: function(res) {
									if (res.confirm) {
										_this.$Router.push({
											path: '/my/address/address'
										})
									}
								}
							});
							this.$openInvite()
						} else {
							_this.showFlag = true
							_this.homelist = uni.getStorageSync('hourseList')[uni.getStorageSync('hourseNum') || 0]
							_this.name = _this.homelist.proName;
							_this.address = _this.homelist.buildDistrictCode + '-' + _this.homelist.buildTowerCode + '-' +
								_this.homelist.roomUnitNumber + '-' + _this.homelist.roomCode

							this.getList()
						}
					} else {
						uni.showModal({
							title: '请先实名认证',
							showCancel: false,
							confirmText: '确认',
							confirmColor: '#F9A832',
							success: function(res) {
								if (res.confirm) {
									_this.$Router.push({
										path: '/homePage1/realName/realName'
									})
								}
							}
						});
					}
				} else {
					uni.showModal({
						title: '请先登录',
						showCancel: false,
						confirmText: '确认',
						confirmColor: '#F9A832',
						success: function(res) {
							if (res.confirm) {
								console.log('a')
								_this.$Router.pushTab({
									path: '/pages/user/user'
								})
							}
						}
					});
				}
				uni.stopPullDownRefresh()
			},
			getList() {
				console.log(this.pageIndex, 'pageindex')
				if (this.pageIndex < 2) {
					uni.showLoading({
						title: '加载中'
					});
				}
				this.loading = false;
				this.$request.api.getMyPosition({
					yeZhuApp: 1,
					pageIndex: this.pageIndex,
					owner_user_id: uni.getStorageSync('rawData').userId
				}).then(res => {
					console.log(uni.getStorageSync('rawData').userId)
					console.log(res)
					if (this.pageIndex == 1) {
						this.listData = res.data.data.datalist || [];
					} else {
						this.listData = [...this.listData, ...res.data.data.datalist];
					}
					console.log(this.listData)
					this.nextPage = res.data.data.isEndPage
					this.loading = true;
					uni.hideLoading();

				})
				uni.stopPullDownRefresh();
			},

		}
	}
</script>

<style lang='scss'>
	.car-wrap {
		background: #f4f4f4;
		width: 100vw;
		height: 100vh;
		overflow: hidden;
		.car-card {
			background: #fff;
			border-radius: 12rpx;
		}
	}
</style>